import pygame
import sys
import os

# 获取当前脚本所在目录
current_dir = os.path.dirname(os.path.abspath(__file__))

# 添加当前目录到Python路径
sys.path.append(current_dir)

# 尝试导入并运行mario.py
try:
    # 检查是否有安装所需的依赖
    import pygame
    print("pygame 模块已安装")
    
    # 运行mario.py
    print("正在启动马里奥游戏...")
    print("使用的是调整为64x64像素的玩家图片")
    
    # 执行mario.py文件 - 指定UTF-8编码
    mario_file = os.path.join(current_dir, 'mario.py')
    with open(mario_file, encoding='utf-8') as f:
        exec(f.read())
        
except ImportError as e:
    print(f"缺少依赖项: {e}")
    print("请运行: pip install pygame")
except Exception as e:
    print(f"启动游戏时出错: {e}")
    
print("游戏已退出")